import { Controller, Get, Post, Body, Patch, Param, Delete, ParseIntPipe, Inject, SetMetadata } from '@nestjs/common'
import { WillesService } from './willes.service'
import { CreateWilleDto } from './dto/create-wille.dto'
import { UpdateWilleDto } from './dto/update-wille.dto'
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'

@Controller({
  path: 'willes',
  version: '1'
})
@ApiTags('willes')
@ApiBearerAuth()
export class WillesController {
  constructor(
    private readonly willesService: WillesService,
    @Inject('willes') private list: number[]
  ) {}

  @Post()
  create(@Body() createWilleDto: CreateWilleDto) {
    return this.willesService.create(createWilleDto)
  }

  @Get()
  @SetMetadata('role', ['admin'])
  async findAll() {
    // const res = await this.willesService.findAll()
    return '11'
  }

  @Get(':id')
  findOne(@Param('id', ParseIntPipe) id: number) {
    console.log('%c [  ]-28', 'font-size:13px; background:#5aa1d3; color:#9ee5ff;', typeof id)
    return this.willesService.findOne(+id)
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateWilleDto: UpdateWilleDto) {
    return this.willesService.update(+id, updateWilleDto)
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.willesService.remove(+id)
  }
}
